package wnhz.com.business.shareshop.activity.mine;

import android.app.Application;
import android.content.Intent;
import android.os.Build;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;

import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import wnhz.com.business.R;
import wnhz.com.business.base.MyBaseActivity;
import wnhz.com.business.groupshop.bean.ShareInfo;
import wnhz.com.business.impl.ActionBarClickListener;
import wnhz.com.business.uitls.dialog.ShareDialog;
import wnhz.com.business.view.TranslucentActionBar;

/**
 * 支付成功
 */
public class PaymentSucceedActivity extends MyBaseActivity implements ActionBarClickListener {
    @BindView(R.id.actionbar)
    TranslucentActionBar actionbar;

    private ShareDialog shareDialog;

    @Override
    protected void handleMsg(Message msg) {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_payment_succeed);
        ButterKnife.bind(this);
        actionbar.setData("支付成功", R.drawable.ic_lefft_white, null, 0, "", 0, this);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            actionbar.setStatusBarHeight(getStatusBarHeight());
        }
    }

    @OnClick({R.id.tv_share})
    public void onViewClicked(View v) {
        switch (v.getId()) {
            case R.id.tv_share:
                share();
                break;
        }
    }

    public void share() {
        //分享
        ShareInfo shareInfo = new ShareInfo();
        shareInfo.title = "小鸟云创";
        shareInfo.text = "专注各种商品商城，优惠多多！";
        shareInfo.targetUrl = "http://www.baidu.com";

        shareDialog = new ShareDialog(PaymentSucceedActivity.this, shareInfo, null, new UMShareListener() {
            @Override
            public void onResult(SHARE_MEDIA platform) {
                Toast.makeText(PaymentSucceedActivity.this, "分享成功", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onError(SHARE_MEDIA platform, Throwable t) {
                Toast.makeText(PaymentSucceedActivity.this, "分享失败", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onCancel(SHARE_MEDIA platform) {
                Toast.makeText(PaymentSucceedActivity.this, "分享取消", Toast.LENGTH_SHORT).show();
            }
        });
        shareDialog.show();
    }


    @Override
    public void onLeftClick() {
        finish();
    }

    @Override
    public void onRightClick() {

    }

    @Override
    public void onEditTextClick() {

    }

    public static Intent createIntent(Application application) {
        Intent intent = new Intent(application, PaymentSucceedActivity.class);
        return intent;
    }
}
